package cn.xyy.system.api;

import cn.xyy.system.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.xyy.common.annotation.log.Log;
import cn.xyy.common.domain.mvc.R;
import cn.xyy.common.domain.system.notice.Notice;
import cn.xyy.common.domain.system.notice.NoticeVO;

/**
 * 通知接口
 * 
 * @author xyy
 *
 */
@RestController
@RequestMapping(value = "/rest/notice")
public class NoticeRest {

	@Autowired
	private NoticeService noticeService;

	@RequestMapping(value = "/getNoticePage", method = RequestMethod.GET)
	public R getMessagePage(NoticeVO vo) {
		return R.ok(noticeService.getMessagePage(vo));
	}

	// @CheckPermission("notice:add")
	@Log("新增消息")
	@RequestMapping(value = "addNotice", method = RequestMethod.POST)
	public R add(@RequestBody Notice notice) {
		noticeService.insert(notice);
		return R.ok();
	}

	// @CheckPermission("notice:edit")
	@Log("修改消息")
	@RequestMapping(value = "updateNotice", method = RequestMethod.POST)
	public R update(@RequestBody Notice notice) {
		noticeService.update(notice);
		return R.ok();
	}

	// @CheckPermission("notice:del")
	@Log("删除消息")
	@RequestMapping(value = "deleteNotice")
	public R delete(@RequestParam("id") Integer id) {
		noticeService.delete(id);
		return R.ok();
	}

	@Log("查看消息")
	@RequestMapping(value = "getNoticeInfo")
	public R getNoticeInfo(@RequestParam("id") Integer id) {
		return R.ok(noticeService.getNoticeInfo(id));
	}

}
